package cn.royan.fl.proxys 
{
	import cn.royan.fl.interfaces.IRequest;
	import cn.royan.fl.services.ClientSocketProtocol;
	import cn.royan.fl.values.ClientConfig;
	import org.puremvc.as3.interfaces.IProxy;
	import org.puremvc.as3.patterns.proxy.Proxy;
	
	/**
	 * ...
	 * @author RoYan
	 */
	public class PacketDispatchProxy extends Proxy implements IProxy 
	{
		public static const NAME:String = "PacketDispatchProxy";
		
		private var clientSocketProxy:ClientSocketProxy;
		private var clientSocketProtocol:ClientSocketProtocol;
		
		public function PacketDispatchProxy() 
		{
			super( NAME );
			
			clientSocketProxy = facade.retrieveProxy( ClientSocketProxy.NAME ) as ClientSocketProxy;
			clientSocketProtocol = ClientConfig( clientSocketProxy.getData() ).socketProtocol;
		}
		
		public function sendPacket( packet:IRequest ):void
		{
			clientSocketProtocol.sendRequest( packet.encode() );
		}
	}

}